package settings.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import settings.domain.User;
import settings.exception.LoginException;
import settings.service.UserService;
import util.JsonUtil;

import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {
    @Autowired
    UserService userService;
    @RequestMapping(value = "/userLoginCheck",method = RequestMethod.POST)
    @ResponseBody
    public String userLoginCheck(HttpServletRequest req) throws LoginException {
        String loginPwd=req.getParameter("loginPwd");
        String loginAct=req.getParameter("loginAct");
        String ip=req.getRemoteAddr();
        User user=userService.userLoginCheckService(loginAct,loginPwd,ip);
        req.getSession().setAttribute("userMessage",user);
        return JsonUtil.ordinaryValueToJson("status","true");
    }
}
